import { AxiosRequestConfig, AxiosResponse } from 'axios'

//创建一个接口对config配置(AxiosRequestConfig)进行约束的扩展
export interface WXRequestInterceptors<T = AxiosResponse> {
  requestInterceptor?: (config: AxiosRequestConfig) => AxiosRequestConfig //请求成功拦截
  requestInterceptorCatch?: (error: any) => any //请求失败拦截

  // 响应拦截
  responseInterceptor?: (res: T) => T //响应成功
  responseInterceptorCatch?: (error: any) => any //响应失败
}

export interface WXRequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  //扩展
  interceptors?: WXRequestInterceptors<T>
  showLoading?: boolean //可选参数，让使用者决定此次请求时是否显示loading组件
}
